--
-- Author: shunguo.chen
-- Date: 2016-10-19 17:42:49
--
-- RewardLevelPanel

local ListViewExtend = require("app.widget.ListViewExtend")
local RewardLevelRender = import(".renders.RewardLevelRender")

local ClassRef = app.mvc.createPanelClass(...)

function ClassRef.create(node)
	local sprite = ClassRef.extend(node or cc.CSLoader:createNode(Res.RewardLevelPanel))
	if node == nil then
		ccui.Helper:doLayout(sprite)
	end
	sprite:init()
	return sprite
end

function ClassRef:init(data)
	self.super.init(self, data)

	self._list = self._ui["Panel/list"]
	self._list:removeAllItems()
	self._list.createRender = function (list, idx)
		local items = list:getItems()
    	local render = items[idx]
    	if nil == render then
			render = RewardLevelRender.create()
			list:pushBackCustomItem(render)
		end
		render:setVisible(true)
		return render
	end
	ListViewExtend.scrollToItemExtend(self._list)
end

function ClassRef:getList()
	return self._list
end

return ClassRef